using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
    /// <summary> 
    ///Author: daiduong19051986@gmail.com 
    /// <summary>

    public class RuleSetInfo
    {
        #region Local Variable
        public enum Field
        {
            AUTO_ID,
            RULESET_CODE,
            COMMAND,
            FIELD,
            START,
            LENGTH,
            OPERATOR,
            VALUE,
            COL0,
            COL1,
            COL2,
            COL3,
            COL4,
            COL5,
            COL6,
            COL7,
            COL8,
            COL9
        }
        private Int32 _AUTO_ID;
        private String _RULESET_CODE;
        private String _COMMAND;
        private String _FIELD;
        private Int32 _START;
        private Int32 _LENGTH;
        private String _OPERATOR;
        private String _VALUE;
        private String _COL0;
        private String _COL1;
        private String _COL2;
        private String _COL3;
        private String _COL4;
        private String _COL5;
        private String _COL6;
        private String _COL7;
        private String _COL8;
        private String _COL9;

        public Int32 AUTO_ID { get { return _AUTO_ID; } set { _AUTO_ID = value; } }
        public String RULESET_CODE { get { return _RULESET_CODE; } set { _RULESET_CODE = value; } }
        public String COMMAND { get { return _COMMAND; } set { _COMMAND = value; } }
        public String FIELD { get { return _FIELD; } set { _FIELD = value; } }
        public Int32 START { get { return _START; } set { _START = value; } }
        public Int32 LENGTH { get { return _LENGTH; } set { _LENGTH = value; } }
        public String OPERATOR { get { return _OPERATOR; } set { _OPERATOR = value; } }
        public String VALUE { get { return _VALUE; } set { _VALUE = value; } }
        public String COL0 { get { return _COL0; } set { _COL0 = value; } }
        public String COL1 { get { return _COL1; } set { _COL1 = value; } }
        public String COL2 { get { return _COL2; } set { _COL2 = value; } }
        public String COL3 { get { return _COL3; } set { _COL3 = value; } }
        public String COL4 { get { return _COL4; } set { _COL4 = value; } }
        public String COL5 { get { return _COL5; } set { _COL5 = value; } }
        public String COL6 { get { return _COL6; } set { _COL6 = value; } }
        public String COL7 { get { return _COL7; } set { _COL7 = value; } }
        public String COL8 { get { return _COL8; } set { _COL8 = value; } }
        public String COL9 { get { return _COL9; } set { _COL9 = value; } }

        #endregion LocalVariable

        #region Constructor
        public RuleSetInfo()
        {
            _AUTO_ID = 0;
            _RULESET_CODE = "";
            _COMMAND = "";
            _FIELD = "";
            _START = -1;
            _LENGTH = -1;
            _OPERATOR = "";
            _VALUE = "";
            _COL0 = "";
            _COL1 = "";
            _COL2 = "";
            _COL3 = "";
            _COL4 = "";
            _COL5 = "";
            _COL6 = "";
            _COL7 = "";
            _COL8 = "";
            _COL9 = "";
        }
        public RuleSetInfo(
        Int32 AUTO_ID,
        String RULESET_CODE,
        String COMMAND,
        String FIELD,
        Int32 START,
        Int32 LENGTH,
        String OPERATOR,
        String VALUE,
        String COL0,
        String COL1,
        String COL2,
        String COL3,
        String COL4,
        String COL5,
        String COL6,
        String COL7,
        String COL8,
        String COL9
        )
        {
            _AUTO_ID = AUTO_ID;
            _RULESET_CODE = RULESET_CODE;
            _COMMAND = COMMAND;
            _FIELD = FIELD;
            _START = START;
            _LENGTH = LENGTH;
            _OPERATOR = OPERATOR;
            _VALUE = VALUE;
            _COL0 = COL0;
            _COL1 = COL1;
            _COL2 = COL2;
            _COL3 = COL3;
            _COL4 = COL4;
            _COL5 = COL5;
            _COL6 = COL6;
            _COL7 = COL7;
            _COL8 = COL8;
            _COL9 = COL9;
        }
        public RuleSetInfo(DataRow dr)
        {
            if (dr != null)
            {
                _AUTO_ID = dr[Field.AUTO_ID.ToString()] == DBNull.Value ? 0 : Convert.ToInt32(dr[Field.AUTO_ID.ToString()]);
                _RULESET_CODE = dr[Field.RULESET_CODE.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.RULESET_CODE.ToString()]);
                _COMMAND = dr[Field.COMMAND.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.COMMAND.ToString()]);
                _FIELD = dr[Field.FIELD.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.FIELD.ToString()]);
                _START = dr[Field.START.ToString()] == DBNull.Value ? 0 : Convert.ToInt32(dr[Field.START.ToString()]);
                _LENGTH = dr[Field.LENGTH.ToString()] == DBNull.Value ? 0 : Convert.ToInt32(dr[Field.LENGTH.ToString()]);
                _OPERATOR = dr[Field.OPERATOR.ToString()] == DBNull.Value ? "=" : Convert.ToString(dr[Field.OPERATOR.ToString()]);
                _VALUE = dr[Field.VALUE.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.VALUE.ToString()]);
                _COL0 = dr[Field.COL0.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.COL0.ToString()]);
                _COL1 = dr[Field.COL1.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.COL1.ToString()]);
                _COL2 = dr[Field.COL2.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.COL2.ToString()]);
                _COL3 = dr[Field.COL3.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.COL3.ToString()]);
                _COL4 = dr[Field.COL4.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.COL4.ToString()]);
                _COL5 = dr[Field.COL5.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.COL5.ToString()]);
                _COL6 = dr[Field.COL6.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.COL6.ToString()]);
                _COL7 = dr[Field.COL7.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.COL7.ToString()]);
                _COL8 = dr[Field.COL8.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.COL8.ToString()]);
                _COL9 = dr[Field.COL9.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.COL9.ToString()]);
            }
        }
        public RuleSetInfo(DataRowView dr) : this(dr.Row) { }

        public RuleSetInfo(RuleSetInfo objEntr)
        {
            _AUTO_ID = objEntr.AUTO_ID;
            _RULESET_CODE = objEntr.RULESET_CODE;
            _COMMAND = objEntr.COMMAND;
            _FIELD = objEntr.FIELD;
            _START = objEntr.START;
            _LENGTH = objEntr.LENGTH;
            _OPERATOR = objEntr.OPERATOR;
            _VALUE = objEntr.VALUE;
            _COL0 = objEntr.COL0;
            _COL1 = objEntr.COL1;
            _COL2 = objEntr.COL2;
            _COL3 = objEntr.COL3;
            _COL4 = objEntr.COL4;
            _COL5 = objEntr.COL5;
            _COL6 = objEntr.COL6;
            _COL7 = objEntr.COL7;
            _COL8 = objEntr.COL8;
            _COL9 = objEntr.COL9;
        }
        #endregion Constructor

        #region InitTable
        public DataTable ToDataTable()
        {
            DataTable dt = new DataTable("RuleSetHVJ");
            dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.AUTO_ID.ToString(), typeof(Int32)),
				new DataColumn(Field.RULESET_CODE.ToString(), typeof(String)),
				new DataColumn(Field.COMMAND.ToString(), typeof(String)),
				new DataColumn(Field.FIELD.ToString(), typeof(String)),
				new DataColumn(Field.START.ToString(), typeof(Int32)),
				new DataColumn(Field.LENGTH.ToString(), typeof(Int32)),
				new DataColumn(Field.OPERATOR.ToString(), typeof(String)),
				new DataColumn(Field.VALUE.ToString(), typeof(String)),
				new DataColumn(Field.COL0.ToString(), typeof(String)),
				new DataColumn(Field.COL1.ToString(), typeof(String)),
				new DataColumn(Field.COL2.ToString(), typeof(String)),
				new DataColumn(Field.COL3.ToString(), typeof(String)),
				new DataColumn(Field.COL4.ToString(), typeof(String)),
				new DataColumn(Field.COL5.ToString(), typeof(String)),
				new DataColumn(Field.COL6.ToString(), typeof(String)),
				new DataColumn(Field.COL7.ToString(), typeof(String)),
				new DataColumn(Field.COL8.ToString(), typeof(String)),
				new DataColumn(Field.COL9.ToString(), typeof(String))
			});
            return dt;
        }
        public DataRow ToDataRow(DataTable dt)
        {
            DataRow row = dt.NewRow();
            row[Field.AUTO_ID.ToString()] = _AUTO_ID;
            row[Field.RULESET_CODE.ToString()] = _RULESET_CODE;
            row[Field.COMMAND.ToString()] = _COMMAND;
            row[Field.FIELD.ToString()] = _FIELD;
            row[Field.START.ToString()] = _START;
            row[Field.LENGTH.ToString()] = _LENGTH;
            row[Field.OPERATOR.ToString()] = _OPERATOR;
            row[Field.VALUE.ToString()] = _VALUE;
            row[Field.COL0.ToString()] = _COL0;
            row[Field.COL1.ToString()] = _COL1;
            row[Field.COL2.ToString()] = _COL2;
            row[Field.COL3.ToString()] = _COL3;
            row[Field.COL4.ToString()] = _COL4;
            row[Field.COL5.ToString()] = _COL5;
            row[Field.COL6.ToString()] = _COL6;
            row[Field.COL7.ToString()] = _COL7;
            row[Field.COL8.ToString()] = _COL8;
            row[Field.COL9.ToString()] = _COL9;
            return row;
        }
        #endregion InitTable
    }
}
